package com.clickpaas.workinghours.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class LogAspect {
    @Pointcut("@annotation(com.clickpaas.workinghours.annotation.ControllerLog)")
    private void log(){}

    @Around("log()")
    public Object LogAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        /**
         * 开始时间
         */
        long startTime = System.currentTimeMillis();
        Object result = proceedingJoinPoint.proceed();
        long endTime = System.currentTimeMillis();
        log.info("程序运行时间：【{}ms】", endTime - startTime);
        return result;
    }
}
